//
//  HuadongView.m
//  B段项目
//
//  Created by 徐茂怀 on 15/11/4.
//  Copyright © 2015年 徐茂怀. All rights reserved.
//

#import "HuadongView.h"
#import "FitHeader.h"
@implementation HuadongView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

-(void)createView
{
    _leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _leftButton.tintColor = [UIColor colorWithRed:0.12 green:0.63 blue:0.59 alpha:1];
    _leftButton.titleLabel.font = [UIFont fontWithName:@"EuphemiaUCAS-Bold" size:22 * FitWidth];
    [_leftButton setTitle:@"详情" forState:0];
    [_leftButton addTarget:self action:@selector(leftButtonAction) forControlEvents:UIControlEventTouchUpInside];
    
    _rightButton = [UIButton buttonWithType:UIButtonTypeSystem];
    _rightButton.tintColor = [UIColor colorWithRed:0.12 green:0.63 blue:0.59 alpha:1];
    _rightButton.titleLabel.font = [UIFont fontWithName:@"EuphemiaUCAS-Bold" size:22 * FitWidth];
    [_rightButton setTitle:@"步骤" forState:0];
    [_rightButton addTarget:self action:@selector(rightButtonAction) forControlEvents:UIControlEventTouchUpInside];
    
    _seprateView = [[UIView alloc]init];
    _seprateView.backgroundColor = [UIColor colorWithRed:0.12 green:0.63 blue:0.59 alpha:1];
    [self addSubview:_leftButton];
    [self addSubview:_rightButton];
    [self addSubview:_seprateView];
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    _leftButton.frame = CGRectMake(0, 0, 187 * FitWidth, 50 * FitHeight);
    _rightButton.frame = CGRectMake(187 * FitWidth, 0 , 188 * FitWidth, 50 * FitHeight);
    _seprateView.frame = CGRectMake(0, 50 * FitHeight, 187 * FitWidth, 4 * FitHeight);
}

-(void)leftButtonAction
{
    [UIView animateWithDuration:.2 animations:^{
        _seprateView.frame = CGRectMake(0, 50 * FitHeight, 187 * FitWidth, 4 * FitHeight);
    }];
}

-(void)rightButtonAction
{
    [UIView animateWithDuration:.2 animations:^{
        _seprateView.frame = CGRectMake(188 * FitWidth, 50 * FitHeight, 187 * FitWidth, 4 * FitHeight);

    }];
}

@end
